
package kaizone.haining.chaobohui.json;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;

import kaizone.haining.chaobohui.json.AppRecommend.LogoUrlModel;

import org.json.JSONArray;
import org.json.JSONObject;

public class AboutDO extends JSONResponse {

    public List<AppRecommend> getData() {
        return data;
    }

    public void setData(List<AppRecommend> data) {
        this.data = data;
    }

    private List<AppRecommend> data;

    public static AboutDO parseJson(String str) {
        AboutDO aboutDO = new AboutDO();
        try {
            JSONObject jsonObject = new JSONObject(str);
            JSONResponse response = JSONResponse.parse(jsonObject);
            aboutDO.setJSONResponse(response);

            JSONObject jsondata = jsonObject.optJSONObject(Data.DATA);
            if (jsondata != null) {
                JSONArray jsonAppArry = jsondata.optJSONArray(AppRecommend.APPRECOMMENDLIST);
                if (jsonAppArry != null) {
                    int length = jsonAppArry.length();
                    ArrayList<AppRecommend> appRecommends = new ArrayList<AppRecommend>();
                    for (int i = 0; i < length; i++) {
                        JSONObject jsonAppRecmd = jsonAppArry.getJSONObject(i);
                        AppRecommend appRecommend = AppRecommend.parse(jsonAppRecmd);
                        appRecommends.add(appRecommend);
                    }
                    aboutDO.setData(appRecommends);
                }
            }
            return aboutDO;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return aboutDO;
    }

}
